package tests.view_tests;

import static org.junit.Assert.*;

import org.junit.*;

import javax.swing.*;

import application.view.gui.MenuBuilder;
import java.awt.event.*;

public class MenuBuilder_test {	
	
	@Test
	public void test_constructor(){
		/* Test that the MenuBuilder constructor actually duplicates menu items and their associated events */
		JMenuBar menuBar = new JMenuBar();
		JMenu menu = new JMenu("Test_menu");
		JMenuItem menuItem = new JMenuItem("Test_item");
		menuItem.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){}
		});
		menu.add(menuItem);
		menuBar.add(menu);
		
		MenuBuilder menuBuilder = new MenuBuilder(menuBar);
		int associatedActions = menuBuilder.getMenuBar().getMenu(0).getItem(0).getAccessibleContext().getAccessibleAction().getAccessibleActionCount();
		assertTrue(associatedActions == 1);
	}


}